package com.ruoyi.common.mq.config;

import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


/**
 * RabbitMQ配置类
 * @author japhet_jiu
 * @version 1.0
 */

@Configuration
public class RabbitMQConfig {
    @Autowired
    private RabbitMqConfigVo rabbitMqConfigVo;

    @Bean
    public Queue testGhlQueue() {
        return new Queue(rabbitMqConfigVo.getTestGhlQueue());
    }


    @Bean
    public DirectExchange fanoutTestGhlExchange(){
        return new DirectExchange(rabbitMqConfigVo.getTestGhlExchange());
    }


    @Bean
    public Binding bindingTestGhl() {
        return BindingBuilder.bind(testGhlQueue()).to(fanoutTestGhlExchange()).with(rabbitMqConfigVo.getTestGhlRouting());
    }

}
